package com.priox.sigar.infraestructura.services;

import com.priox.sigar.domain.bean.ExcelExporter;
import com.priox.sigar.domain.bean.ExcelProperties;
import com.priox.sigar.domain.service.ExcelConverter;
import com.priox.sigar.util.ExcelUtil;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.Date;
import java.util.List;

/**
 * User: Matrix
 * Date: 23/01/13
 */
@Component
public class ExcelConverterImpl implements ExcelConverter {

    private static final Logger LOG = Logger.getLogger(ExcelConverterImpl.class);

    public File procesarExcel(File archivoOrigen, ExcelProperties properties) {
        Date inicio = new Date();
        List cellVectorHolder = ExcelUtil.obtenerFilasValidas(archivoOrigen, properties);
        Date fin = new Date();
        LOG.info("total de filas "+cellVectorHolder.size()+ " "+((fin.getTime()-inicio.getTime())/1000));
        File resultado=new ExcelExporter("reporte",properties.getCeldasInfo()).crearExcelData(cellVectorHolder, "datos");
        return resultado;
    }



}
